import axios from "../../http/http"

const store = {
    namespaced: true,
    state(){
        return {
            goodsList:[],
            goodsCount: 0
        }
    },
    mutations: {
        goodsListMutations(state,list){
            state.goodsList = list
        },
        goodsCountMutations(state,count){
            state.goodsCount = count
        }
    },
    actions: {
        goodsListActions(context,page=1,size=2){
            axios.get("/goodslist",{params:{page:page,size:size}}).then(
                res=>{
                    context.commit("goodsListMutations",res.data.list)
                }
            )
        },
        goodsCountActions(context){
            axios.get("/goodscount").then(
                res=>{
                    context.commit("goodsCountMutations",res.data.list[0].total)
                }
            )
        }
    }
}

export default store